package org.os.framework.context.config;

import javax.annotation.Resource;

import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.OkHttp3ClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;

import okhttp3.OkHttpClient;

/**
 * @author
 */
@Configuration
public class RestTemplateConfig {

    @Resource
    private OkHttpClient okHttpClient;

    @Bean
    public RestTemplate restTemplate(RestTemplateBuilder builder) {
        return builder.requestFactory(() -> new OkHttp3ClientHttpRequestFactory(okHttpClient))
                .build();
    }
}
